package cn.wise.rocketmq.producerdemo1.api._02_producer_type;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

import java.util.concurrent.CountDownLatch;

public class OneWayProducer {
    public static void main(String[] args) throws Exception {
        //创建一个生产者对象
        DefaultMQProducer producer = new DefaultMQProducer("wise-producer");
        //2 设置nameserver的地址
        producer.setNamesrvAddr("192.168.147.128:9876;192.168.147.129:9876");
        //启动生产者
        producer.start();
        //创建一个message对象
        for (int i = 0; i < 100; i++) {
            //同步的方式
            Message message = new Message("02-producer_type", "hello,rocketmq".getBytes("utf-8"));
            //一次性消费方式发送
            producer.send(message);
        }
        //关闭生产者
        producer.shutdown();
    }
}
